package warehouse;

import java.util.ArrayList;
import java.util.Collection;
import person.Guest;

public class Table extends Resource{

	public Table(boolean disponibility, int tableNumber, int seatNumber) {
		super(disponibility);
		this.tableNumber = tableNumber;
		this.seatNumber = seatNumber;
		guests = null;
	}

	
	public Table(long id, boolean disponibility, int tableNumber, int seatNumber) {
		super(id, disponibility);
		this.tableNumber = tableNumber;
		this.seatNumber = seatNumber;
		guests = null;
	}

	public Table(long id, boolean disponibility, int tableNumber, int seatNumber, Collection<Guest> guests) {
		super(id, disponibility);
		this.tableNumber = tableNumber;
		this.seatNumber = seatNumber;
		this.guests = guests;
	}
	public int getTableNumber() {
		return tableNumber;
	}
	public void setTableNumber(int tableNumber) {
		this.tableNumber = tableNumber;
	}
	public int getSeatNumber() {
		return seatNumber;
	}
	public void setSeatNumber(int seatNumber) {
		this.seatNumber = seatNumber;
	}
	
	public Collection<Guest> getGuests() {
		return guests;
	}

	public void setGuests(Collection<Guest> guests) {
		if(guests.size() > seatNumber)
			throw new IllegalStateException();
		this.guests = guests;
	}
	
	public void addGuest(Guest guest){
		if(guests == null)
			guests = new ArrayList<Guest>();
		else{
			if(guests.size() + 1 > seatNumber)
				throw new IllegalStateException();
		}
		guests.add(guest);
	}
	private int tableNumber;
	private int seatNumber;
	private Collection<Guest> guests;
}
